﻿create PROCEDURE Sync.SP_UsersProjects_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        t.[ProjectID],t.[UserID],
		
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[UsersProjects] g RIGHT JOIN Sync.UsersProjects_Tracking t  
    ON t.ProjectID = g.ProjectID AND t.UserID = g.UserID 
    join [UsersCommittees] uc on uc.[UserID] = g.[UserID]
	WHERE (@LastRowVersion IS NULL OR t.Version > @LastRowVersion)
	AND ((@FilterdColumn IS NULL) OR (uc.CommitteeID = @FilterdColumn))
    END














